package com.zsc.wxapp.mapper;

import com.zsc.wxapp.entity.PrintTask;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PrintTaskMapper {

    /**
     * 插入任务数据
     * @param task
     */
    @Insert("insert into print_task (submit_user_id, receive_user_id, price_tag_ids, create_time) " +
            "value (#{submitUserId}, #{receiveUserId}, #{priceTagIds}, #{createTime})")
    void insertTask(PrintTask task);

    /**
     * 根据id获取到任务数量
     * @param userId
     * @return
     */
    @Select("select count(*) from print_task where receive_user_id = #{userId}")
    Integer getTasksNum(Long userId);

    /**
     * 根据用户id获取任务列表
     * @param userId
     * @return
     */
    @Select("select * from print_task where receive_user_id = #{userId}")
    List<PrintTask> getPrintTaskList(Long userId);
}
